const sequelize = require('../config/connect.js')//引入数据库连接文件
const config = require('../config/config.js')//引入数据库配置文件
const myorder = require('./myorder.js')//订单表
const { Op, Model, DataTypes } = require('sequelize')//引入nodejs的orm模型文件

class timeExtension   extends Model{}  //续费延长信息表 

timeExtension.init({
    operatingId:{
        type:DataTypes.INTEGER,
        primaryKey:true,
        comment:'操作记录号'
    },
    orderNumber:{
        type:DataTypes.STRING(32),
        allowNull:false,
        references:{
            model:myorder,
            key:'orderNumber'
        },
        comment:'操作的订单号'
    },
    oldExpiryDate:{
        type:DataTypes.DATE,
        allowNull:false,
        comment:'住房原到期日期'
    },
    newExpiryDate:{
        type:DataTypes.DATE,
        allowNull:false,
        comment:'住房新到期日期'
    },
    addedMoney:{
        type:DataTypes.INTEGER,
        allowNull:false,
        comment:'需要添加的金额'
    }
},{
    sequelize,
    charset:config.charset,
    timestamps:false,
    freezeTableName:true,
    modelName:'timeExtension'    
})

module.exports = timeExtension;
